package com.woniuxy;

import com.woniuxy.entity.BoyFriend;
import com.woniuxy.entity.Dog;
import com.woniuxy.test.Person;
import com.woniuxy.test.impl.Chinese;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource;

public class TestDay01 {
    public static void main(String[] args) {
//        第一种方式
//        BeanFactory beanFactory = new XmlBeanFactory(new FileSystemResource("H:\\0.蜗牛学院--整合管理资料\\备课资料\\1.备课资料\\乐山理工\\learning-spring\\day02-IOC\\src\\main\\resources\\applicationContext.xml"));
//        Object dog2 = beanFactory.getBean("dog");
//        System.out.println(dog2);
//        第二种方式
//        在原型模式下，每次getBean的时候，我们获取到的对象地址都不同
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        BoyFriend ren = applicationContext.getBean("boy",BoyFriend.class);
        System.out.println(ren);
        BoyFriend ren1 = applicationContext.getBean("boy",BoyFriend.class);
        System.out.println(ren1);
        BoyFriend ren2 = applicationContext.getBean("boy",BoyFriend.class);
        System.out.println(ren2);
    }
}
